import * as echarts from 'echarts';

const userData:echarts.EChartsCoreOption ={
  title:{
    text:'部门员工数据',
    padding:[
      20,0,0,180
    ]
  },
  tooltip:{
    trigger:'axis',
    axisPointer: {
      type: 'shadow'
    },
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    height:'80%',
    containLabel: true
  },
  xAxis:{
    type:'category',
    data:['人事部','销售部','创新部','游戏部'],
    axisTick: {
      alignWithLabel: true
    }
  },
  yAxis:{
    type:'value'
  },
  series: [
    {
      name: '人数',
      type: 'bar',
      barWidth: '60%',
      data: [10, 52, 20, 20]
    }
  ]
}

function defaultChart(){
  const aim = echarts.init(document.getElementById('aim'))
  
  
  if(aim!=null&&aim!=undefined){
    drawChart(aim,userData)
  }
}

function drawChart(aim:echarts.ECharts,data:echarts.EChartsCoreOption){
  aim.setOption(data)
}


export default function useChart(){
  return {
    defaultChart
  }
}